﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __XOS_ODBC_ODBC_FIELD_H__
#define __XOS_ODBC_ODBC_FIELD_H__

#include "../tools/head.h"
#include "include_odbc.h"

namespace xos_odbc
{

    class odbc_field : public xos_stl::mem_item< odbc_field, thread_lock >
    {
    public:
        typedef odbc_field T;

    public:
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
        odbc_field();
        ~odbc_field();

    public:
        i_stmt::enumValueType m_eType;
        std::string m_name;
        int m_nIndex;
        int m_nDigitnum;
        int m_nBufSize;
        union{
            xos::xos_i64 * i64_ptr;
            xos::xos_i32 * i32_ptr;
            xos::xos_i16 * i16_ptr;
            xos::xos_i8 * i8_ptr;
            xos::xos_u64 * u64_ptr;
            xos::xos_u32 * u32_ptr;
            xos::xos_u16 * u16_ptr;
            xos::xos_u8 * u8_ptr;
            bool * bool_ptr;
            double * double_ptr;
            float * float_ptr;
            char * char_ptr;
        };
        xos::xos_int len_or_ptr;
        bool m_bIsKey;
        bool m_bDirty;

    public:
        int bind_param( i_stmt * pStmt );
        int bind_col( i_stmt * pStmt );
        int clear_value();

    protected:
        int init_data();

    public:
        int release();
        int init();
        int term();
    };

} // xos_odbc

#endif // __XOS_ODBC_ODBC_FIELD_H__
